<template>
  <view class="index-notice" v-if="!hideNoticeBar">
    <u-notice-bar :text="noticeTextList" @click="noticeClick" url="pages/package3/noticeCenter/noticeCenter"
      direction="column"></u-notice-bar>
  </view>
</template>

<script>
  /**
   * @description 首页公告
   * @date 2022-03-12
   * @version v1.0.1
   * @author gf
   */
  export default {
    name: 'index-nav',
    data() {
      return {
        noticeList: [],
        hideNoticeBar:false,
      }
    },
    computed: {
      noticeTextList() {
        let list = []
        for (var i in this.noticeList) {
          list.push(this.noticeList[i].biaoti)
        }
        return list
      }
    },
    mounted() {
      this.getIndexNotice()
    },
    methods: {
      // 获取首页公告
      getIndexNotice() {
        setTimeout(() => {
          // this.noticeList = [{
          //     nid: 'n1',
          //     biaoti: '共青团河南省委副书记王强一行莅临中原资产'
          //   },
          //   {
          //     nid: 'n2',
          //     biaoti: '中原资产携手两家爱心企业向濮阳市捐赠抗疫物资，助力抗疫'
          //   },
          //   {
          //     nid: 'n3',
          //     biaoti: '惠农补贴有多少？打开“普惠通”就知道！驻马店率先实现惠'
          //   },
          //   {
          //     nid: 'n4',
          //     biaoti: '中原资产组织开展“能力作风建设年”健步走活动'
          //   },
          // ]
          console.log(!this.noticeList.length)
          if(!this.noticeList.length){
            this.hideNoticeBar = true
          }
        }, 500)
      },
      // 首页导航点击
      noticeClick(index) {
        console.log(index)
        const item = this.noticeList[index]
        this.$u.route({
          url: 'pages/package3/noticeDetail/noticeDetail',
          params: {
            id: item.nid
          }
        })
      }
    }
  }
</script>

<style lang="scss">
  .index-notice {
    overflow: hidden;
    border-radius: 10upx;
  }
</style>
